<?php 
defined('RUN_KATANA') or die('Restricted access');
class Payment
{
	public $Methods;
	public $SiteMethods;
	public $Shipping;
	
	public function Payment($shipping=0) 
	{ 
		if($shipping > 0)
		{ self::setShipping($shipping); }
		self::loadMethods(); 
	}
	
	public function getMethods() 
	{ return $this->Methods; }
	public function getShipping() 
	{ return $this->Shipping; }
	public function getMethod($id=0) 
	{ 
		if(isset($this->Methods[$id]))
		{ return $this->Methods[$id]; }
	}
	
	public function setShipping($val) 
	{ $this->Shipping=$val; }
	
	public function loadMethods() 
	{ 
		global $shop;
		$select  = 'SELECT id, site_id, title, library, description, ready_status, complete_status, type, active FROM '.DB_PERFIX.'shop_payment p ';
		$select .= 'WHERE active=1 AND (p.site_id='.SITE_ID.' OR p.site_id=0);';
		$result = mysql_query($select);
		if(mysql_num_rows($result) > 0)
		{
			while($row = mysql_fetch_array($result))
			{
				/*
				if($_REQUEST['shipping_method'])
				{
					if($shop->GlobalSettings['shipping_payment'][$_REQUEST['shipping_method']][$row['id']])
					{
						foreach(array_keys($row) as $key)
						{ $this->Methods[$row['id']][$key] = $row[$key]; }
					}
				}
				else
				{
					*/
					foreach(array_keys($row) as $key)
					{ $this->Methods[$row['id']][$key] = $row[$key]; }
					/*
				}*/
			}
		}
	}
}
?>